<?php

namespace app\modules\home\controllers;

use app\components\API;
use app\models\First;
use app\models\Log;
use app\models\money\MoneyPay;
use yii\captcha\CaptchaAction;
use \yii\web\Controller;
use Yii;
use app\components\PlayModel\GPlay;
use app\components\Pay\AlipayPack\sdk\Alipay;
class ApiController extends Controller {

    public $layout = 'main_m';
    public $enableCsrfValidation = false;


    /**
     * 支付宝的支付回调
    */
    public function actionNotify_alipay(){
     //   $_POST=json_decode('{"gmt_create":"2020-08-24 08:38:04","charset":"UTF-8","seller_email":"253347797@qq.com","subject":"\u5145\u503c","sign":"F1WTc+V25EK8RLjAy+C+XxyELczlHl+3+MjvArn\/CbQ6zrAJswxVRsLJ\/4WmhtVzfAJVPXSdlgzruj5CbL4nVnPGc0nJXBvcLZhuZDz7K8BGQzluuYLZ7TGlN344Sb7Y04XtQnTAX+Lj0hnrMw8RkMg0fUK8Ao5iLxOp3KR8Am76C033p5R\/jxOdv9sCLtZL8x8F7mJkyA3UpXubHQUVKDiN8rO+98gpDp\/fdx\/bM2o43oAW8+X3mrOncBP4iYJQjxDselACBZbqR\/OXJBzNj1StHP\/fr2OY9AwxfzXUsf4cpVKZ9aMWyoZMmlKkXuWXZA+hv32+A5BzuOUN1f20kg==","body":"dsdfdsgdr","buyer_id":"2088402803654435","invoice_amount":"0.01","notify_id":"2020082400222083805054430519639289","fund_bill_list":"[{\"amount\":\"0.01\",\"fundChannel\":\"ALIPAYACCOUNT\"}]","notify_type":"trade_status_sync","trade_status":"TRADE_SUCCESS","receipt_amount":"0.01","buyer_pay_amount":"0.01","app_id":"2019072565963731","sign_type":"RSA2","seller_id":"2088821871237492","gmt_payment":"2020-08-24 08:38:05","notify_time":"2020-08-24 09:03:23","version":"1.0","out_trade_no":"aaaaaaaaaaaaa2","total_amount":"0.01","trade_no":"2020082422001454430520337003","auth_app_id":"2019072565963731","buyer_logon_id":"son***@foxmail.com","point_amount":"0.00"}',true);

        Log::addText(json_encode($_POST));
         $pay=new Alipay;
         if($pay->notify()&&MoneyPay::NotifyPay('zhifubao',\Yii::$app->request->post('out_trade_no'),
                 \Yii::$app->request->post('trade_no'))){
             ///本平台的订单号
           /*  $out_trade_no = $_POST['out_trade_no'];
             //支付宝交易号
             $trade_no = $_POST['trade_no'];
             //交易状态
             $trade_status = $_POST['trade_status'];
            */


             echo "success";		//请不要修改或删除
         }else{
             echo "fail";	//请不要修改或删除
         }
    }
    public function actionSuccess(){
        echo "success";
    }


    public $title = '测试系统';
    public $description = '测试系统';

}
